﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class UIWBBEW : ViewBase
    {
        public VWBBEW TMV
        {
            get
            {
                return (VWBBEW)MV;
            }
        }
        #region ==dwWB===========
        public static readonly DependencyProperty dwWBProperty = DependencyProperty.Register("dwWB",
            typeof(DataRow), typeof(UIWBBEW),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwWBChanged));
        public DataRow dwWB
        {
            get
            {
                return (DataRow)GetValue(dwWBProperty);
            }
            set
            {
                SetValue(dwWBProperty, value);
            }
        }
        private static void OndwWBChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWBBEW;
            if (src != null)
            {
                src.dwWB = (DataRow)e.NewValue;
            }
        }
        #endregion
        #region ==dwWB14===========
        public static readonly DependencyProperty dwWB14Property = DependencyProperty.Register("dwWB14",
            typeof(DataRow), typeof(UIWBBEW),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwWB14Changed));
        public DataRow dwWB14
        {
            get
            {
                return (DataRow)GetValue(dwWB14Property);
            }
            set
            {
                SetValue(dwWB14Property, value);
            }
        }
        private static void OndwWB14Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWBBEW;
            if (src != null)
            {
                src.dwWB14 = (DataRow)e.NewValue;
            }
        }
        #endregion
        #region ==WBEWBS===========
        public static readonly DependencyProperty WBEWBSProperty = DependencyProperty.Register("WBEWBS",
            typeof(string), typeof(UIWBBEW),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWBEWBSChanged));
        public string WBEWBS
        {
            get
            {
                return (string)GetValue(WBEWBSProperty);
            }
            set
            {
                SetValue(WBEWBSProperty, value);
            }
        }
        private static void OnWBEWBSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWBBEW;
            if (src != null)
            {
                src.WBEWBS = (string)e.NewValue;
            }
        }
        #endregion
        #region ==WBEWBELEG===========
        public static readonly DependencyProperty WBEWBELEGProperty = DependencyProperty.Register("WBEWBELEG",
            typeof(string), typeof(UIWBBEW),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWBEWBELEGChanged));
        public string WBEWBELEG
        {
            get
            {
                return (string)GetValue(WBEWBELEGProperty);
            }
            set
            {
                SetValue(WBEWBELEGProperty, value);
            }
        }
        private static void OnWBEWBELEGChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWBBEW;
            if (src != null)
            {
                src.WBEWBELEG = (string)e.NewValue;
            }
        }
        #endregion

        #region ==RWAUF===========
        public static readonly DependencyProperty RWAUFProperty = DependencyProperty.Register("RWAUF",
            typeof(string), typeof(UIWBBEW),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnRWAUFChanged));
        public string RWAUF
        {
            get
            {
                return (string)GetValue(RWAUFProperty);
            }
            set
            {
                SetValue(RWAUFProperty, value);
            }
        }
        private static void OnRWAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIWBBEW;
            if (src != null)
            {
                src.RWAUF = (string)e.NewValue;
            }
        }
        #endregion
        public UIWBBEW()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 
        }
       
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);

        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwWB14 = dwMaster;
            if (dwMaster == null)
            {
                RWAUF = "";
            }
            else
            { 
                RWAUF = dwMaster["WBEWRWKRS"].ToString() + dwMaster["WBEWRWLFD"].ToString() + dwMaster["WBEWPOS"].ToString();
            }
        } 

    }
}
